import type React from "react";
import DI from "../../utils/di";

abstract class BaseControlService extends DI {
  abstract label: React.ReactNode;
  abstract component: React.FC<any>;
  abstract init(): void;
  visible: boolean = true;
  setVisible(visible: boolean) {
    this.visible = visible;
  }

  getLabelWidth(): number {
    if (typeof this.label === 'string') {
      return this.label.length * 14 + 24;
    } else {
      return 100;
    }
  }

  onShow() {
    // 在加载时执行一些初始化动作
  }
}

export default BaseControlService;
